﻿using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Albatross.SharePoint.Explorer.ViewModels {
	public class EventReceiverViewModel : ClientObjectViewModel {
		public EventReceiverViewModel(ClientContext context, string name, EventReceiverDefinition receiver)
			: base(context, name, receiver) {
		}

		public EventReceiverDefinition Receiver { get { return (EventReceiverDefinition)ClientObject; } }

		public override string GetContentTitle() {
			if (Name == string.Empty) {
				if (string.IsNullOrEmpty(Receiver.ReceiverName)) {
					return Convert.ToString(Receiver.ReceiverId);
				} else {
					return Receiver.ReceiverName;
				}
			} else {
				return Name;
			}
		}
		public override string GetTreeItemTitle() {
			if (string.IsNullOrEmpty(Receiver.ReceiverName)) {
				return Convert.ToString(Receiver.ReceiverId);
			} else {
				return Receiver.ReceiverName;
			}
		}
	}
}
